﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Browser;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using DYSales.Web;

namespace DYSales
{
    public enum EditMode
    {
        Add, Edit, Noting
    }

    public enum em_角色
    {
        收银员, 财务员, 仓库管理员, 店长
    }

    public class autoPd
    {
        public string pdName { get; set; }
        public PdTable pd { get; set; }

        public override string ToString() { return pdName; }
    }

    public class dm
    {
        internal static DateTime loginedTime { get; set; }
        static DomainService1 ds;
        internal static DomainService1 getDS()
        {
            if (ds == null)
            {
                ds = new DomainService1();
            }
            return ds;
        }

        internal static void checkLogined()
        {
            if (WebContext.Current.User.Name == string.Empty)
            {
                dm.refreshApp();
            }
        }

        internal static void refreshApp()
        {
            if (App.Current.IsRunningOutOfBrowser)
            {
                App.Current.MainWindow.Close();
            }
            else
            {
                HtmlPage.Window.Navigate(new Uri(GetCurrentUrl()));
            }
        }

        internal static string GetCurrentUrl()
        {
            var url = Application.Current.Host.Source.AbsoluteUri;
            var fileName = System.IO.Path.GetFileName(url);
            return url.Replace("/ClientBin/" + fileName, "");
        }

    }
}
